<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title></title>
		<style>
			#div{
				width: 200px;
				height: 200px;
				border: 2px solid  black;
			}
		</style>
	</head>
	<body>
		<h2>点击项目框框：红绿交替</h2>
		<div id="div" onclick="change()"></div>
		<script>
			function change() {
				var bg=document.getElementById('div')
				/*bg.style.backgroundColor="red";*/
				bg.style.backgroundColor=
				(bg.style.backgroundColor=='red'?'green':'red');
				
			}
		</script>
	</body>
</html>
